<?php
	header("Content-Type: text/html;charset=utf-8");
	include("function/_nosql.php"); //
	include("function/function.php");
	$kboy_userid = $_SESSION['kboy_userid'];
	$kboy_user = $_SESSION['kboy_user'];

	$action = chkstr(trim($_REQUEST['action']));
	$tid = chkstr(trim($_REQUEST['tid']));
	$newsid = chkstr(trim($_REQUEST['newsid']));//线路编号
	if($kboy_userid){
	  if($action == "add"){ //添加关注
		if(empty($tid)){
			echo "参数错误";
			exit();
		}
		if(!is_numeric($tid)){
			echo "参数错误";
			exit();
		}
		if($kboy_userid == $tid){
			echo "请勿对自己进行操作";
			exit();
		}
		
		
		if(getNewsNums("kboy_forum_friend","uid=$kboy_userid and tid=$tid")>0){
			echo "该用户已关注，请勿重复操作";
			exit();
		}

		$mysql = new sqlstr("kboy_forum_friend"); 
		$mysql -> set("uid",$kboy_userid,true);
		$mysql -> set("tid",$tid,true);
		$news_sql = $mysql -> insertSql();
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo "关注成功";
			exit();
		}else{
			echo "服务器内部错误";
			exit();
		}
	 }
	 else if($action == "addfavoriteactive"){//感兴趣的路线
	    if(empty($newsid)){
			echo "参数错误";
			exit();
		}
		if(!is_numeric($newsid)){
			echo "参数错误";
			exit();
		}
		if(getNewsNums("kboy_forum_favorite","uid=$kboy_userid and newsid=$newsid")>0){
			echo "该用户已点击，请勿重复操作";
			exit();
		}
		$mysql = new sqlstr("kboy_forum_favorite"); 
		$mysql -> set("uid",$kboy_userid,true);
		$mysql -> set("newsid",$newsid,true);
		$news_sql = $mysql -> insertSql();
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo "点击成功";
			exit();
		}else{
			echo "服务器内部错误";
			exit();
		}
	 }
	 else{
	    echo "参数错误";
		exit();
	 }
		
	}else{
		echo "请登录后操作";
		exit();
	}
?>